package stz.flash.main.flashlight.field;

import net.rim.device.api.system.Application;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Manager;
import blackberry.util.field.DjHighlightManager;

public class HighlightManagerForFlashMode extends DjHighlightManager{

	private static boolean focusable = true;
	private static Field lastFocusField;
	
	public HighlightManagerForFlashMode(int focusedColor, int selectedColor, int globalAlpha, 
			Manager delegateManager) {
		super(focusedColor, selectedColor, globalAlpha, delegateManager);
	}


	public boolean isFocusable() {
		return focusable;
	}

	public static void setFocusable(boolean focusable) {
		HighlightManagerForFlashMode.focusable = focusable;

		if (focusable && lastFocusField != null)
			synchronized (Application.getEventLock()) {
				lastFocusField.setFocus();
			}
	}

	protected void onFocus(int i) {
		lastFocusField = this;
		super.onFocus(i);
	}

	protected void initFocusField(Field field) {
		lastFocusField = field;
	}
}
